import fetch from 'common/src/utils/fetch';
import cryp from 'common/src/utils/secret';
/**
 * 查询学生个人课表
 */
function findStudentTimetab(calendarId, studentCode) {
    let url =
        '/api/electionservice/reportManagement/findStudentTimetab?calendarId=' +
        calendarId;
    if (studentCode) {
        url += '&studentCode=' + cryp.encrypt(studentCode.toString());
    }else{
        console.log(123)
    }
    return fetch({
        url: url,
        method: 'get'
    });
}
//查询研究生个人课表
function findGraduateStudentTimetab(calendarId, studentCode) {
    let url =
        '/api/electionservice/reportManagement/findSchoolTimetab2?calendarId=' +
        calendarId + '&studentCode=' + cryp.encrypt(studentCode.toString());
    return fetch({
        url: url,
        method: 'get'
    });
}

/**
 * 查询学生课表对应老师时间地点
 */
function findStudentAndTeacherTime(teachingClassId) {
    return fetch({
        url:
            '/api/electionservice/reportManagement/findStudentAndTeacherTime?teachingClassId=' +
            teachingClassId,
        method: 'get'
    });
}
//研究生学生课表导出
function exportStudentTimetabPdf(params) {
    let query = '?';
    for (let key in params) {
        if(key == 'studentCode') {
            query += key;
            query += '=';
            query += cryp.encrypt(params[key].toString());
            query += '&';
        } else {
            query += key;
            query += '=';
            query += params[key];
            query += '&';
        }
    }
    return '/api/electionservice/reportManagement/exportStudentTimetabPdf' + query.substring(0, query.length - 1)
}

// 本科生学生课表导出
function exportStudentTimetab(params) {
    let query = '?';
    for (let key in params) {
        if(key == 'studentCode') {
            query += key;
            query += '=';
            query += cryp.encrypt(params[key].toString());
            query += '&';
        } else {
            query += key;
            query += '=';
            query += params[key];
            query += '&';
        }
    }
    return '/api/electionservice/reportManagement/exportStudentTimetab' + query.substring(0, query.length - 1)
}

export default {
    findStudentTimetab: findStudentTimetab,
    findAllSchoolTimetabUrl: '/api/electionservice/reportManagement/findAllSchoolTimetab',
    graduateFindAllSchoolTimetabUrl: '/api/electionservice/reportManagement/findStudentTimeTableByRole',
    findStudentAndTeacherTime: findStudentAndTeacherTime,
    findGraduateStudentTimetab: findGraduateStudentTimetab, //研究生的学生个人课表
    exportStudentTimetabPdf: exportStudentTimetabPdf, //研究生导出学生课表
    exportStudentTimetab: exportStudentTimetab
};
